package com.walkud.rxjava.utils;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

/**
 * RxJava观察者(订阅者)适配器
 *
 * @param <T>
 */
public abstract class RxSubscribe<T> implements Observer<T> {
    @Override
    public void onSubscribe(Disposable d) {
        System.out.println("onSubscribe()");
    }

    @Override
    public void onNext(T t) {
        System.out.println("onNext():" + t);
        call(t);
    }

    @Override
    public void onError(Throwable e) {
        System.out.println("onError():" + e.getMessage());
    }

    @Override
    public void onComplete() {
        System.out.println("onComplete()");
    }

    public abstract void call(T t);
}
